/*
 Copyright (C) 2009 are of boxtorrents
 boxtorrents, azureus, vuze, and java are copyrighted to their respective owner.

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; version 2 of the License.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */
package com.boxtorrents.azureus;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.gudy.azureus2.plugins.PluginInterface;

/**
 * Event used on {@link StatCheckListener}
 * 
 * @author are of boxtorrents
 */
public class StatCheckEvent implements Serializable {
	private static final long serialVersionUID = -8705511853647579078L;
	/**
	 * good ratio
	 */
	public static int EVENT_NORMAL = 0;
	/**
	 * warning ratio
	 */
	public static int EVENT_WARNING = 1;
	/**
	 * danger ratio
	 */
	public static int EVENT_DANGER = 2;
	private Date date;
	private int eventType = -1;
	private PluginInterface pluginInterface;
	private String uploadSize;
	private String downloadSize;
	private float ratio;
	private Set<TorrentData> torrents = new HashSet<TorrentData>();

	/**
	 * @param date
	 * @param eventType
	 * @param pluginInterface
	 * @param uploadSize
	 * @param downloadSize
	 * @param ratio
	 */
	public StatCheckEvent(Date date, int eventType,
	    PluginInterface pluginInterface, String uploadSize, String downloadSize,
	    float ratio) {
		super();
		this.date = date;
		this.eventType = eventType;
		this.pluginInterface = pluginInterface;
		this.uploadSize = uploadSize;
		this.downloadSize = downloadSize;
		this.ratio = ratio;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return this.date;
	}

	/**
	 * @param date the date to set
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * @return the downloadSize
	 */
	public String getDownloadSize() {
		return this.downloadSize;
	}

	/**
	 * @param downloadSize the downloadSize to set
	 */
	public void setDownloadSize(String downloadSize) {
		this.downloadSize = downloadSize;
	}

	/**
	 * @return the eventType
	 */
	public int getEventType() {
		return this.eventType;
	}

	/**
	 * @param eventType the eventType to set
	 */
	public void setEventType(int eventType) {
		this.eventType = eventType;
	}

	/**
	 * @return the pluginInterface
	 */
	public PluginInterface getPluginInterface() {
		return this.pluginInterface;
	}

	/**
	 * @param pluginInterface the pluginInterface to set
	 */
	public void setPluginInterface(PluginInterface pluginInterface) {
		this.pluginInterface = pluginInterface;
	}

	/**
	 * @return the ratio
	 */
	public float getRatio() {
		return this.ratio;
	}

	/**
	 * @param ratio the ratio to set
	 */
	public void setRatio(float ratio) {
		this.ratio = ratio;
	}

	/**
	 * @return the uploadSize
	 */
	public String getUploadSize() {
		return this.uploadSize;
	}

	/**
	 * @param uploadSize the uploadSize to set
	 */
	public void setUploadSize(String uploadSize) {
		this.uploadSize = uploadSize;
	}

	/**
	 * @inheritDoc
	 */
	@Override
	public String toString() {
		return "Uploaded: " + getUploadSize() + "\nDownloaded: "
		    + getDownloadSize() + "\nRatio: " + getRatio() + " ("
		    + Math.round(getRatio() * 100) + "%)" + "\n[" + getDate() + "]";
	}

	/**
	 * Collection of torrent that known by {@link DataGatherer}
	 * 
	 * @return collection of {@link TorrentData}
	 */
	public Set<TorrentData> getTorrentData() {
		return this.torrents;
	}

	/**
	 * @param torrentdata
	 */
	public void setTorrents(Set<TorrentData> torrentdata) {
		this.torrents = torrentdata;
	}
}
